<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="com.jm.web.data.PageResult" %>
<%@ page import="com.jm.web.data.BaseDataEntities" %>
<%@include file="/include/common/gridbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	private String param1 = "";
	private String param2 = "";
	
	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量
	protected void prepareActionEnv() throws Exception{
		param1 = utils.getHrNum();
		param2 = utils.getChName();
	}
	
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		return true ;
	}
	
	//处理查询的驗證
	protected void onSearchValidate() throws Exception{
		super.onSearchValidate();
	}
	
	// 取出查询結果
	protected void onSearchRetrieveResult() throws Exception{}
	
	//處理每一行的數據
	protected void  itemRender(BaseDataEntity rowData) throws Exception{}
	
	//取出查詢語句
	protected String onSearchGetSql() throws Exception{
		StringBuilderEx whr =  new StringBuilderEx("1=1");
		return whr.toString();
	}
	
	//处理自定義操作
	protected boolean onCustomAction(String action) throws Exception{
		if("getMenuData".equals(action)){
			return getMenuData();
		}
		return super.onCustomAction(action);
	}
	
	private boolean getMenuData() throws Exception{
		PageResult pageResult = ret.getCallResult();
		String lastsn = form.gpsv("sn","1");
		ResultSet rs = utils.executeQuery("pan","select srt,sn,lastsn, "
		+"	'tree_'+rtrim(ltrim(convert(char(10),sn))) as id,"
		+"	right(cast(power(10,2) as varchar)+srt,2)+' '+name  as text,src,case src when '' then 'false' else 'true' end as leaf"
		+"	from pan..menu where lastsn = '"+lastsn+"' and enab = 1 and [public] = 1 order by srt");
		pageResult.getData().SetParamValue("nodes",BaseDataEntities.FromResultSet(rs));
		this.getPage().Output(pageResult.getData().ToJSONString());
		return true;
	}
}
%>
<%@include file="/include/common/gridbackend.jsp"%>